package com.ruoyi.web.controller.web.stat;

import com.ruoyi.common.core.domain.WrapperResponse;
import com.ruoyi.system.habit.service.StatService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: xujiabing
 * @date: 2024-10-15 9:52
 * @description 统计控制器
 */
@RestController
@Slf4j
@Api("习惯统计")
public class StatController {
    @Autowired
    private StatService statService;

    /**
     * @description: 查询用户总数
     * @author: xujiabing
     * @date: 2024-10-23 20:06
     * @param:
     * @return: WrapperResponse<Long>
     */
    @ApiOperation("查询用户总数")
    @PreAuthorize("@ss.hasPermi('habit:stat:userTotals')")
    @GetMapping("/web/stat/userTotals")
    public WrapperResponse<Long> queryUserTotals() {
        return WrapperResponse.success(statService.queryUserTotals());
    }

    /**
     * @description: 查询打卡记录总数
     * @author: xujiabing
     * @date: 2024-10-23 20:07
     * @param:
     * @return: WrapperResponse<Long>
     */
    @ApiOperation("查询打卡记录总数")
    @PreAuthorize("@ss.hasPermi('habit:stat:checkInTotals')")
    @GetMapping("/web/stat/checkInTotals")
    public WrapperResponse<Long> queryCheckInTotals() {
        return WrapperResponse.success(statService.queryCheckInTotals());
    }

    /**
     * @description: 查询今日打卡数
     * @author: xujiabing
     * @date: 2024-10-23 20:14
     * @param:
     * @return: WrapperResponse<Long>
     */
    @ApiOperation("查询今日打卡数")
    @PreAuthorize("@ss.hasPermi('habit:stat:checkInToday')")
    @GetMapping("/web/stat/checkInToday")
    public WrapperResponse<Long> queryCheckInToday() {
        return WrapperResponse.success(statService.queryCheckInToday());
    }

    /**
     * @description: 查询今日打卡-用户数量
     * @author: xujiabing
     * @date: 2024-10-23 20:14
     * @param:
     * @return: WrapperResponse<Long>
     */
    @ApiOperation("查询今日打卡-用户数量")
    @PreAuthorize("@ss.hasPermi('habit:stat:todayUsers')")
    @GetMapping("/web/stat/todayUsers")
    public WrapperResponse<Long> queryUserCheckInToday() {
        return WrapperResponse.success(statService.queryUserCheckInToday());
    }

    /**
     * @description: 查询习惯总数
     * @author: xujiabing
     * @date: 2024-10-23 20:18
     * @param:
     * @return: WrapperResponse<Long>
     */
    @ApiOperation("查询习惯总数")
    @PreAuthorize("@ss.hasPermi('habit:stat:habits')")
    @GetMapping("/web/stat/habits")
    public WrapperResponse<Long> queryHabitsTotals() {
        return WrapperResponse.success(statService.queryHabitsTotals());
    }

    /**
     * @description: 查询番茄总时长
     * @author: xujiabing
     * @date: 2024-10-23 20:20
     * @param:
     * @return: WrapperResponse<Long>
     */
    @ApiOperation("查询番茄总时长")
    @PreAuthorize("@ss.hasPermi('habit:stat:tomatos')")
    @GetMapping("/web/stat/tomatos")
    public WrapperResponse<Long> queryTomatoTimesTotals() {
        return WrapperResponse.success(statService.queryTomatoTimesTotals());
    }

    /**
     * @description: 今日番茄总时长
     * @author: xujiabing
     * @date: 2024-10-23 20:22
     * @param:
     * @return: WrapperResponse<Long>
     */
    @ApiOperation("今日番茄总时长")
    @PreAuthorize("@ss.hasPermi('habit:stat:todayTomatos')")
    @GetMapping("/web/stat/todayTomatos")
    public WrapperResponse<Long> queryTomatoToday() {
        return WrapperResponse.success(statService.queryTomatoToday());
    }

}
